<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>CopyBatchOrder</title>
    <!--<link rel="stylesheet" href="../../webjar/plugins/layui/css/layui.css">-->
    <!--<link rel="stylesheet" href="../../webjar/bootstrap/3.3.7-1/css/bootstrap.min.css">-->
    <!--<link rel="stylesheet" href="../../webjar/bootstrap-table/bootstrap-table.css">-->
    <!--<link href="http://netdna.bootstrapcdn.com/font-awesome/4.0.1/css/font-awesome.min.css" rel="stylesheet">-->
    <!--<link rel="stylesheet" href="../../webjar/css/mystyle.css">-->

    <!--<script src="../../webjar/jquery/3.1.1/jquery.min.js" type="text/javascript"></script>-->
    <!--<script src="../../webjar/bootstrap/3.3.7-1/js/bootstrap.min.js"></script>-->
    <!--<script src="../../webjar/bootstrap-table/bootstrap-table.js"></script>-->
    <!--<script src="../../webjar/bootstrap-table/bootstrap-table-zh-CN.min.js" type="text/javascript"  charset="UTF-8"></script>-->
    <!--<script src="../../webjar/layer/layer.js" type="text/javascript"></script>-->
    <!--<script src="../../webjar/plugins/layui/layui.js" type="text/javascript"></script>-->
    <!--<script src="../Public/ServerPath.js" type="text/javascript"></script>-->
    <!--<script src="../Public/TuLayer.js" type="text/javascript"></script>-->

    <!--<script type="text/javascript" src="../Public/ibcpAjax.js"></script>-->
    <!--<script type="text/javascript" src="../Public/ibcpLayer.js"></script>-->
    <!--<script type="text/javascript" src="../Public/Sign.js"></script>-->
    <script src="../Public/DateFormat.js" type="text/javascript"></script>
</head>
<body>
<form class="form-horizontal" role="form" style="padding:15px;">
    <div class="form-group" >
        <label class="col-xs-4 control-label">批指令号：</label>
        <div class="col-xs-8">
            <input type="text" class="form-control" id="BatchOrder_Code_Copy" placeholder="请输入批指令号">
        </div>
    </div>

    <div class="form-group" >
        <label class="col-xs-4 control-label">批号：</label>
        <div class="col-xs-8">
            <input type="text" class="form-control" id="Batch_Code_Copy" placeholder="请输入批号">
        </div>
    </div>
    <div class="form-group">
        <label for="Copy_Product_Name" class="col-xs-4 control-label">产品名称：</label>
        <div class="col-xs-8">
            <input type="text" class="form-control" id="Copy_Product_Name" readonly="true">
        </div>
    </div>
    <div class="form-group" >
        <label class="col-xs-4 control-label">批量：</label>
        <div class="col-xs-8">
            <div class="input-group">
                <input type="text" class="form-control" id="Batch_Quantity_Copy" placeholder="请输入批量">
                <span id="Batch_Copy_Unit" class="input-group-addon"></span>
            </div>
        </div>
    </div>

    <div class="form-group" >
        <label class="col-xs-4 control-label">批指令类型：</label>
        <div class="col-xs-8">
            <select class="form-control" id="BatchOrder_Type_Copy">
                <option value="1">正式</option>
                <option value="2">模拟</option>
            </select>
        </div>
    </div>

    <div class="form-group" >
        <label class="col-xs-4 control-label">计划生产日期：</label>
        <div class="col-xs-8">
            <input type="date" name="bday" class="form-control" id="BatchOrder_PlanDate_Copy">
        </div>
    </div>

    <div class="form-group" style = "margin-top: 15px;margin-bottom: 0px">
        <div class="col-xs-6" style="text-align: right">
            <button type="button" id="Copy_BatchOrder_Confirm" class="btn btn-custom">确定</button>
        </div>
        <div class="col-xs-6" style="text-align: left">
            <button type="button" id="Copy_BatchOrder_Cancel" class="btn btn-custom close-layer">取消</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    var copyBatchOrderPath = serverPath + "Order/copyOrder";
    console.log(copyBatchOrderPath);

    $(function(){
        CopyPageShowBasic();
       initMethod();
    });

    //加载基本信息
    function CopyPageShowBasic(){
        var select = $('#tableBatchOrder').bootstrapTable('getSelections')[0];
        $('#Copy_Product_Name').val(select.materialCodeName);
        $('#Batch_Quantity_Copy').val(select.planQuantity);
        $('#Batch_Copy_Unit').text(select.uomSymbol);
    }

    //初始化功能
    function initMethod(){
        'use strict';
        //日期选择限制
        var fom = new ibcpDateFormat();
        var minDate = fom.FormatDate("yyyy-MM-dd");
        $('#BatchOrder_PlanDate_Copy').attr('min', minDate);

        //确定按钮事件
        $('#Copy_BatchOrder_Confirm').on('click', function(){
            var check = checkEmptyTips();
            if(check == false) return;
            var orderId = $('#tableBatchOrder').bootstrapTable('getSelections')[0].id;
            Signature.CallSign(100, function(sid){
                var datas = {
                    "id": orderId,
                    "orderNo": $('#BatchOrder_Code_Copy').val(),
                    "planQuantity": $('#Batch_Quantity_Copy').val(),
                    "batchNo": $('#Batch_Code_Copy').val(),
                    "typeId": $('#BatchOrder_Type_Copy').find("option:selected").val(),
                    "planDate": $('#BatchOrder_PlanDate_Copy').val() + " 00:00:00",
                    "sid": sid
                };
                ibcpAjax.Insert(copyBatchOrderPath, datas, true, function(result) {
                    TuLayer.ShowOK("拷贝成功！");
                    Signature.CloseSign();
                    TuLayer.Close();
                    GetBatchOrderList();
                });
            });
        });
    }

    //检查非空
    function checkEmptyTips(){
        'use strict';
        var check = true;
        $('input').each(function(){
            if($(this).val() == ""){
                ibcpLayer.ShowTips('请填写',$(this));
                check = false;
            }
        });
        return check;
    }
</script>
</body>
</html>